<!--include file='./Public/Base/User/login.html' /-->

	<div style='margin-top:0px'>
	<div style='text-align:center'>用户登陆</div>
	<form action='__URL__/login_c' method='post' >
		<div style='margin:0 auto;width:150px;margin-top:10px'>
			<div style='margin-bottom:5px'>邮　箱： </div>
			<div>
				<input name = 'userName' />
			</div>
		</div>

		<div style='margin:0 auto;width:150px;margin-top:10px'>
			<div style='margin-bottom:5px'>密　码： </div>
			<div>
				<input type='password' name = 'pwd' />
			</div>
		</div>

		<div style='margin:0 auto;width:150px;margin-top:10px'>
			<div style='margin-bottom:5px'>验证码： </div>
			<div>
				<input name = 'vCode' />
			</div>
		</div>
		<div style='margin:0 auto;width:150px;height:50px;margin-top:10px'>
			<img src='__URL__/vCode' style='width:100%;height:100%' onclick="this.src='__URL__/vCode?a='+Math.random()"/>
		</div>

		<div style='text-align:center;margin-top:20px'>
			<button type='button' id='login_submit'>登陆</button>
			<button type='button' id='login_register'>注册</button>
		</div>
		<div style='text-align:center;margin-top:20px;font-size:12px'>
			忘记密码？
			<span style='color:blue;cursor:pointer' id='Login_FindPwd'>找回</span>
		</div>
	</form>
	</div>
	
	<div style='margin:0 auto;width:100px;margin-top:10px;height:28px'>
		<a href='{$url}'>
			<img src='http://fang-images.b0.upaiyun.com/system/weibo_login.png' style='width:100%;height:100%' />
		</a>
	</div>


<script>



	//登陆
	$("#login_submit").click(function(){
	//	alert('<?php echo Token_Set('login_c_ajax');?>');
		var userName = $('input[name=userName]').val();
		var pwd = $('input[name=pwd]').val();
		var vCode = $('input[name=vCode]').val();
		if(!userName.trim() || !pwd.trim() || !vCode.trim()){
			alert('登陆信息不得为空！');exit;
		}
		var p = /^\w+@\w+\.[a-z]{2,3}$/;
		if(!p.test(userName)){
			alert('邮箱格式不正确！');exit;
		}
		$.ajax({
			url:'__URL__/login_c_ajax',
			type:'post',
			data:{
				token:'<?php echo Token_Set('login_c_ajax');?>',
				userName:userName,
				pwd:pwd,
				vCode:vCode
			},
			success:function(res){
				switch(res){
					case "e1":
						alert('登陆信息不得为空!');
						user_login();
						break;
					case "e2":
						alert('验证码不正确！');
						user_login();
						break;
					case "e3":
						alert('用户名或密码不正确！');
						user_login();
						break;
					case "ok":
						alert('登陆成功！');
						sessionStorage.userInfo = true;
						$.ajax({
							url:'__APP__/'+sessionStorage.ModuleName+'/Before/index',
							success:function(res){
								$("body").html(res);
							}
						});
						break;
					default:
						alert('非法访问！');
						user_login();
				}
			}
		});
	});

	function user_login(){
		$.ajax({
			url:'__APP__/User/User/login',
			success:function(res){
				$('#content').html(res);
				sessionStorage.Page_Login = escape(res);
			}
		});
	}

	//注册跳转
	$("#login_register").click(function(){
		$.ajax({
			url:'__URL__/register',
			success:function(res){
				$('#content').html(res);
				sessionStorage.Register = escape(res);
			}
		});
	});


	//点击找回密码
	$('#Login_FindPwd').click(function(){
		$.ajax({
			url:'__URL__/pwd_find',
			success:function(res){
				$('#content').html(res);
				sessionStorage.PwdFind = escape(res);
			}
		});
	});

</script>

